package freaksServer;

import java.net.*;
import java.io.*;

public class ServerThread extends Thread {
	private Socket socket = null;

    public ServerThread(Socket socket) {
    	super("ServerThread");
    	this.socket = socket;
    }

    public void run() {

	try {
		PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
        BufferedReader in = new BufferedReader(
				new InputStreamReader(
				socket.getInputStream()));
        String inputLine, outputLine;
      
        out.println("Say something, client. I will repeat it!");

        while ((inputLine = in.readLine()) != null) {
             outputLine = inputLine;
             out.println(outputLine);
             if (outputLine.equals("Bye."))
                break;
        }
        out.close();
        in.close();
	    socket.close();

	} catch (IOException e) {
	    e.printStackTrace();
	}
    }
}
